﻿using B.S.BasicData.Api.Write.Application.Command.Log;
using B.S.BasicData.ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.BasicData.Api.Write.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class LogController : ControllerBase
    {
        private readonly IMediator mediator;

        /// <summary>
        /// 通过构造函数注入中介者组件
        /// </summary>
        public LogController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 添加日志接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> CreateLog(CreateLogCommand request) { 
            return mediator.Send(request);
        }
        /// <summary>
        /// 更新日志接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public Task<ApiResult<int>> UpdateLog(UpdateLogCommand request) {
            return mediator.Send(request);
        }
        /// <summary>
        /// 删除日志接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public Task<ApiResult<int>> DelLog(DelLogCommand request)
        {
            return mediator.Send(request);
        }
    }
}
